package mockbase;

import org.powermock.api.mockito.PowerMockito;
import org.testng.annotations.Test;

public class Mock1 {

    @Test
    private void t1() {
        Animal mock = PowerMockito.mock(Animal.class);

        PowerMockito.doReturn(null).when(mock).printName();

        PowerMockito.doReturn(100).when(mock).likeFood(9);


    }

    /**
     * 编译通过，但是导致错误的写法
     * UnfinishedStubbingException
     */
    @Test
    private void t2() {
        Animal mock = PowerMockito.mock(Animal.class);

        PowerMockito.doReturn(null).when(mock.getAgePlus1());

        PowerMockito.doNothing().when(mock.typeName("cat"));

//        PowerMockito.doNothing().when(mock.printName());
//
//        PowerMockito.doCallRealMethod().when(mock.printName());
    }

}
